home *** CD-ROM | disk | FTP | other *** search
- Path: tech.cftnet.com!not-for-mail
- From: wcowley@cftnet.com (Wes Cowley)
- Newsgroups: comp.lang.c++
- Subject: Re: Proper use of friend keyword
- Date: 2 Apr 1996 10:53:10 GMT
- Organization: CFTnet
- Message-ID: <4jr0um$ste@tech.cftnet.com>
- References: <4jn38u$j9c@holly.ACNS.ColoState.EDU>
- NNTP-Posting-Host: ppp250_4.cftnet.com
- X-Newsreader: TIN [UNIX 1.3 950824BETA PL0]
-
- Corby S. Hudnall (corbyh@holly.ACNS.ColoState.EDU) wrote:
- [ ... ]
- : class ABC
- : {
- : int AValue;
- : int GetAValue() { return (AValue); }
- : public:
- : ABC() { AValue=5; }
- : ~ABC(){ }
- : };
- :
- : class XYZ
- : {
- : public:
- : XYZ() { }
- : ~XYZ() { }
- : friend int ABC::GetAValue();
- : };
- [ ... ]
- : when I try to compile this, I get the message "no member funciton
- : 'XYZ::GetAValue()' defined." What do I need to do in order to
- : make this work. Thanks for any and all suggestions.
-
- It looks like you've got a bit of a misunderstanding of what friend does.
- In the classes above, the friend declaration says that ABC's GetAValue()
- can access private and protected members of XYZ. It does not add a
- new member function to XYZ.
-
- Wes
-